﻿<UserControl x:Class="MContracts.View.ContractFcView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Model="clr-namespace:MCDomain.Model;assembly=MCDomain" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
     
        <HierarchicalDataTemplate x:Key="FunctionalCustomerTreeViewItemTemplate" DataType="{x:Type Model:Functionalcustomer}" ItemsSource="{Binding Path=Functionalcustomers}">
            <Border BorderBrush="Cornsilk" BorderThickness="2" CornerRadius="4">
                <StackPanel>
                    <TextBlock Foreground="Brown" Text="{Binding Functionalcustomertype}"></TextBlock>
                    <TextBlock FontWeight="Medium" Text="{Binding Name}"></TextBlock>                        
                    <TextBlock Text="{Binding Path=Contractor.Name}"></TextBlock>
                </StackPanel>
            </Border>

        </HierarchicalDataTemplate>
    </UserControl.Resources>

    <Expander Name="FcExpanderControl" IsExpanded="{Binding IsMaximized, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Background="{StaticResource Expander-Background-FC-Brush}" MaxHeight="300" >
        <Expander.Header>
            <WrapPanel >
                <Image Source="/MContracts;component/Images/personal.png" Width="30"></Image>
                <Label>Функциональные заказчики</Label>
            </WrapPanel>
        </Expander.Header>
        <Expander.Content>
            <Border BorderThickness="4" CornerRadius="4" Padding="2" Background="{StaticResource ResourceKey=Expander-Fc-Background-Brush}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                        <ColumnDefinition Width="30"></ColumnDefinition>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                    </Grid.ColumnDefinitions>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="*"></RowDefinition>
                    </Grid.RowDefinitions>


                    <StackPanel Grid.Row="1" Grid.Column="2" SnapsToDevicePixels="True">
                        <StackPanel.ScrollOwner>
                            <ScrollViewer />
                        </StackPanel.ScrollOwner>
                        <Label>Список функциональных заказчиков</Label>
                        <ScrollViewer x:Name="scr" Margin ="0,5,0,0"   HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="220" VerticalScrollBarVisibility="Auto">
                            <TreeView Margin ="0,5,0,0"  HorizontalAlignment="Stretch" Name="FunctionalCustomersTreeView" VerticalAlignment="Stretch" ItemsSource="{Binding FunctionalCustomers, Mode=OneTime}" ItemTemplate="{StaticResource FunctionalCustomerTreeViewItemTemplate}" IsTextSearchEnabled="True" MouseDoubleClick="FunctionalCustomersTreeView_MouseDoubleClick" />
                        </ScrollViewer>

                    </StackPanel>
                    <DataGrid  Margin="0,5,0,0" Grid.Row="1" Grid.Column="0" HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding Path=ContractFunctionalCustomersBindingList, Mode=OneTime}" CanUserAddRows="False" HeadersVisibility="Column" AutoGenerateColumns="False" x:Name="CustomersDataGrid" MouseDoubleClick="CustomersDataGrid_MouseDoubleClick">
                        <DataGrid.Columns>
                            <DataGridTemplateColumn Width="*" Header="Функциональный заказчик" IsReadOnly="True">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Border BorderThickness="1" BorderBrush="Azure" CornerRadius="2">
                                            <StackPanel>
                                                <Label Content="{Binding Path=Customer.Contractor}" FontWeight="Heavy"></Label>
                                                <Label Content="{Binding Customer}" FontWeight="Light"></Label>
                                            </StackPanel>
                                        </Border>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                                
                            </DataGridTemplateColumn>
                           
                        </DataGrid.Columns>
                    </DataGrid>

                    <StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center">
                        <Button Style="{StaticResource Flat}" Click="Button_Click_1">
                            <Image Source="/MContracts;component/Resources/Back.png" ToolTip="Добавить заказчика" ImageFailed="Image_ImageFailed"></Image>
                        </Button>

                        <Button Margin="0,10,0,0" Style="{StaticResource Flat}" Click="Button_Click">
                            <Image Source="/MContracts;component/Resources/Forvard.png" ToolTip="Убрать из списка"></Image>
                        </Button>
                    </StackPanel>
                </Grid>
            </Border>
        </Expander.Content>
    </Expander>

</UserControl>
